<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.0.js"></script>
	<title>Document</title>

	<style type="text/css">
		table{border-collapse:collapse;border-spacing:0;border-left:1px solid #888;border-top:1px solid #888;background:#efefef;}
		th,td{border-right:1px solid #888;border-bottom:1px solid #888;padding:5px 15px;}
		th{font-weight:bold;background:#ccc;}
	</style>
</head>
<body>
	<table >
		<tr>
			<th><input type="checkbox" id="all" value="1" onclick="checkAll()">all</th>
			<th>id</th>
		</tr>
		<tr>
			<td><input type="checkbox" name="id" value="1"></td>
			<td>1</td>
		</tr>
		<tr>
			<td><input type="checkbox" name="id" value="2"></td>
			<td>2</td>
		</tr>
		<tr>
			<td><input type="checkbox" name="id" value="3"></td>
			<td>3</td>
		</tr>
	</table>

	<input type="checkbox" name="chk_list" id="chk_list_1" value="1" />1<br />
	<input type="checkbox" name="chk_list" id="chk_list_2" value="2" />2<br />
	<input type="checkbox" name="chk_list" id="chk_list_3" value="3" />3<br />
	<input type="checkbox" name="chk_list" id="chk_list_4" value="4" />4<br />
	<input type="checkbox" name="chk_all" id="chk_all" />全选/取消全选

	<div>
		<input type="checkbox" id="isAgeSelected"/>
		<div id="txtAge" style="display:none">Age is something</div>​
	</div>

	<script type="text/javascript">
		function checkAll() {
			var all = document.getElementById("all");
			var checks = document.getElementsByName("id");
			var length = checks.length;
			for (var i = 0; i < length; i++) {
				checks[i].checked = all.checked;
			}
		}

		//$(function () {

			$("#chk_all").click(function(){
		    	//$("input[name='chk_list']").attr("checked",$(this).attr("checked"));
		    	//$("input[name='chk_list']").attr("checked",$(this).prop("checked"));
		    	//$("input[name='chk_list']").attr("checked",$(this).is(":checked"));

		    	var flag = this.checked;
		    	alert(flag);
		    	$("input[name='chk_list']").each(function() {
		    		$(this).attr("checked", flag);
		    		//$(this).prop("checked", flag);
		    		//$(this).prop("checked", flag);
		    	});

			});

			$('#isAgeSelected').click(function () {
			    $("#txtAge").toggle(this.checked);
			});

		//});
	</script>
</body>
</html>